package com.tobestronger.mypay.controller;


import com.tobestronger.mypay.dao.entity.Product;
import com.tobestronger.mypay.service.ProductService;
import com.tobestronger.mypay.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/product")
@CrossOrigin //跨域
@Api(tags="商品管理") //用在类上
public class ProductController {

    @Resource
    private ProductService productService;


    @ApiOperation("商品列表")
    @GetMapping("/list")
    public R list(){
        List<Product> list = productService.list();
        return R.ok().data("productList", list);
    }


}
